<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢迎注册</title>

    <meta charset="UTF-8">
    <title>login</title>
    <script src="../js/vue.js"></script>
    <script src="../element-ui/lib/index.js"></script>
    <link rel="stylesheet" href="../element-ui/lib/theme-chalk/index.css">
    <script src="../js/axios-0.18.0.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f4f4f4;
        }
        .register-container {
            background-color: #fff;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
            width: 400px;
            text-align: center;
        }
        .register-container h2 {
            margin-bottom: 20px;
            color: #333;
        }
        .register-container input[type="text"],
        .register-container input[type="email"],
        .register-container input[type="password"],
        .register-container input[type="tel"] {
            width: calc(100% - 22px);
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        .register-container input[type="button"] {
            width: 100%;
            padding: 10px;
            background-color: #28a745;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        .register-container input[type="button"]:hover {
            background-color: #218838;
        }
        .password-group {
            display: flex;
            flex-direction: column;
        }
        .password-group label {
            margin-bottom: 5px;
        }
    </style>
</head>
<body>

<div id="app">
    <div class="register-container">
        <h2>医院挂号系统注册</h2>
        <div style="text-align: left">
            已有账号<a href="userLogin.html">登录</a>
        </div>
        <form action="/your-register-endpoint" method="post">
            <input type="text" name="name" placeholder="请输入姓名" v-model="user.userName" required>
            <input type="tel" name="phone" placeholder="请输入手机号码" v-model="user.phoneNum" required>
            <input type="tel" name="accountNum" placeholder="请输入一个账号" v-model="user.accountNum" required>
            <input type="tel" name="idCard" placeholder="输入身份证号" v-model="user.idcard" required>
            <div style="text-align: left">
                年龄：
                <template>
                    <el-input-number v-model="user.age" :min="1" :max="120" label="描述文字"></el-input-number>
                </template>
            </div>
            <div style="text-align: left">
                <template>
                    <el-radio v-model="user.sex" label="男">男</el-radio>
                    <el-radio v-model="user.sex" label="女">女</el-radio>
                </template>
            </div>
            <div class="password-group">
                <label for="password">密码:</label>
                <input type="password" id="password" name="password" placeholder="请输入密码" v-model="user.pwd" required>
<!--                <label for="confirm-password">确认密码:</label>-->
<!--                <input type="password" id="confirm-password" name="confirm-password" placeholder="请再次输入密码" required>-->
            </div>
            <input type="button" value="注册" @click="regis">
        </form>
    </div>

</div>



<script>
    new Vue({
        el:"#app",
        data(){
            return{
                user:{
                    userName:'',
                    pwd:'',
                    accountNum:'',
                    sex:'',
                    age:'',
                    idcard:'',
                    phoneNum:''
                }
            }
        },

        methods:{
            regis(){
                axios.post("http://localhost:8080/users/register",this.user).then(resp=>{
                    if(resp.data.code === 0){
                        this.$message.error(resp.data.msg);
                    }else{
                        this.$message.success(resp.data.msg);
                        window.location.href="userFrame.html"
                    }
                })
            }
        }
    })
</script>
</body>
</html>